﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Events.aspx.cs" Inherits="TicketingSystemAsp.Events" %>

<%--<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>--%>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ListView ID="EventsListView" runat="server" DataKeyNames="CategoryID" ItemPlaceholderID="ItemPlaceHolder"
        OnItemEditing="EditEvent" OnItemUpdating="UpdateEvent" OnItemDeleting="DeleteEvent"
        OnItemInserting="AddEvent" InsertItemPosition="None">
        <LayoutTemplate>
            <table>
                <tr>
                    <th>
                        Event Title
                    </th>
                    <th>
                        Event Time
                    </th>
                    <th>
                        Category
                    </th>
                    <th>
                        Location
                    </th>
                    <th>
                        Price
                    </th>
                </tr>
                <asp:PlaceHolder ID="ItemPlaceHolder" runat="server" />
                <tr>
                    <td>
                        <asp:LinkButton ID="AddButton" runat="server" Text="Add" CommandName="Add" OnCommand="ShowInsertTemplate"></asp:LinkButton>
                    </td>
                </tr>
            </table>
        </LayoutTemplate>
        <ItemTemplate>
            <tr>
                <td>
                    <asp:Literal ID="Literal1" Text='<%# Eval("EventTitle") %>' runat="server" Mode="Encode"></asp:Literal>
                    <asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("EventID") %>' Visible="false" />
                </td>
                <td>
                    <asp:Literal ID="Literal2" Text='<%# Eval("EventTime").ToString() %>' runat="server"
                        Mode="Encode"></asp:Literal>
                </td>
                <td>
                    <asp:Literal ID="Literal3" Text='<%# Eval("Category.CategoryName") %>' runat="server"
                        Mode="Encode"></asp:Literal>
                </td>
                <td>
                    <asp:Literal ID="Literal4" Text='<%# Eval("Location.LocationName") %>' runat="server"
                        Mode="Encode"></asp:Literal>
                </td>
                <td>
                    <asp:Literal ID="Literal5" Text='<%# String.Format("{0:f2}", Eval("Price")) %>' runat="server"
                        Mode="Encode"></asp:Literal>
                </td>
                <td>
                    <asp:LinkButton ID="EditButton" runat="server" Text="Edit" CommandName="Edit"></asp:LinkButton>
                </td>
                <td>
                    <asp:LinkButton ID="DeleteButton" runat="server" Text="Delete" CommandName="Delete"></asp:LinkButton>
                </td>
            </tr>
        </ItemTemplate>
        <EditItemTemplate>
            <tr>
                <td>
                    <asp:TextBox ID="TitleTextBox" Text='<%# Eval("EventTitle") %>' runat="server" Mode="Encode" />
                    <asp:Label ID="EventIDLabel" runat="server" Text='<%# Eval("EventID") %>' Visible="false" />
                </td>
                <td>
                    <asp:Calendar ID="Calendar" runat="server" Mode="Encode"></asp:Calendar>
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="CategoriesDropDownList">
                    </asp:DropDownList>
                    <asp:Label ID="HiddenCategoryIdLabel" runat="server" Visible="false" Text='<%# Eval("CategoryID")%>'></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="LocationDropDownList" runat="server">
                    </asp:DropDownList>
                    <asp:Label ID="HiddenLocationIdLabel" runat="server" Visible="false" Text='<%# Eval("LocationID")%>'></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="PriceLabel" Text='<%# String.Format("{0:f2}", Eval("Price")) %>'
                        runat="server" Mode="Encode"></asp:TextBox>
                </td>
                <td>
                    <asp:LinkButton ID="UpdateButton" Text="Update" CommandName="Update" runat="server"></asp:LinkButton>
                </td>
            </tr>
        </EditItemTemplate>
        <InsertItemTemplate>
            <tr>
                <td>
                    <label>
                        Title:
                    </label>
                </td>
                <td>
                    <asp:TextBox runat="server" ID="NewTitleTextBox" />
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Time:
                    </label>
                </td>
                <td>
                    <asp:Calendar ID="NewTimeCalendar" runat="server"></asp:Calendar>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Category:
                    </label>
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="NewCategory">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Location:
                    </label>
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="NewLocation">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        Price:
                    </label>
                </td>
                <td>
                    <asp:TextBox ID="NewPrice" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:LinkButton ID="UpdateButton" runat="server" Text="Insert" CommandName="Insert"></asp:LinkButton>
                </td>
            </tr>
        </InsertItemTemplate>
    </asp:ListView>
</asp:Content>
